package com.andnux.android.network;

import android.content.Context;
import android.content.SharedPreferences;

import com.andnux.android.MainApp;

public class CacheUtils {

    public static String getToken() {
        MainApp app = MainApp.getApp();
        String packageName = app.getPackageName();
        SharedPreferences sharedPreferences = app.getSharedPreferences(packageName, Context.MODE_PRIVATE);
        return sharedPreferences.getString("token", null);
    }

    public static void setToken(String token) {
        MainApp app = MainApp.getApp();
        String packageName = app.getPackageName();
        SharedPreferences sharedPreferences = app.getSharedPreferences(packageName, Context.MODE_PRIVATE);
        sharedPreferences.edit().putString("token", token).apply();
    }

    public static String getString(String key) {
        MainApp app = MainApp.getApp();
        String packageName = app.getPackageName();
        SharedPreferences sharedPreferences = app.getSharedPreferences(packageName, Context.MODE_PRIVATE);
        return sharedPreferences.getString(key, null);
    }

    public static void setString(String key,String value) {
        MainApp app = MainApp.getApp();
        String packageName = app.getPackageName();
        SharedPreferences sharedPreferences = app.getSharedPreferences(packageName, Context.MODE_PRIVATE);
        sharedPreferences.edit().putString(key, value).apply();
    }

}
